{
  "version": 2,
  "name": "Traffic Light Intersection",
  "exported": "2026-09-28T00:00:00.000Z",
  "program": [
    {
      "id": 1,
      "rn": 0,
      "comment": "─── PHASE STATE  ─  C1=NS Green  C2=NS Yellow  C3=All Red 1  C4=EW Green  C5=EW Yellow  C6=All Red 2 ───",
      "elements": [
        {
          "id": 100,
          "kind": "contact",
          "type": "XIO",
          "addr": "C2"
        },
        {
          "id": 101,
          "kind": "contact",
          "type": "XIO",
          "addr": "C3"
        },
        {
          "id": 102,
          "kind": "contact",
          "type": "XIO",
          "addr": "C4"
        },
        {
          "id": 103,
          "kind": "contact",
          "type": "XIO",
          "addr": "C5"
        },
        {
          "id": 104,
          "kind": "contact",
          "type": "XIO",
          "addr": "C6"
        },
        {
          "id": 105,
          "kind": "output",
          "type": "OTE",
          "addr": "C1"
        }
      ]
    },
    {
      "id": 2,
      "rn": 1,
      "comment": "NS Green base timer — 20 s",
      "elements": [
        {
          "id": 106,
          "kind": "contact",
          "type": "XIC",
          "addr": "C1"
        },
        {
          "id": 107,
          "kind": "block",
          "type": "TON",
          "addr": "T1",
          "pre": 20000
        }
      ]
    },
    {
      "id": 3,
      "rn": 2,
      "comment": "NS ped extension timer — runs 5 s after T1 times out if ped request is latched (C10)",
      "elements": [
        {
          "id": 108,
          "kind": "contact",
          "type": "XIC",
          "addr": "C1"
        },
        {
          "id": 109,
          "kind": "contact",
          "type": "XIC",
          "addr": "T1/DN"
        },
        {
          "id": 110,
          "kind": "contact",
          "type": "XIC",
          "addr": "C10"
        },
        {
          "id": 111,
          "kind": "block",
          "type": "TON",
          "addr": "T7",
          "pre": 5000
        }
      ]
    },
    {
      "id": 4,
      "rn": 3,
      "comment": "Advance NS Green → NS Yellow  (immediately if no ped req, or after 5 s extension)",
      "elements": [
        {
          "id": 112,
          "kind": "parallel",
          "type": "parallel",
          "addr": "",
          "branches": [
            [
              {
                "id": 114,
                "kind": "contact",
                "type": "XIC",
                "addr": "C1"
              },
              {
                "id": 115,
                "kind": "contact",
                "type": "XIC",
                "addr": "T1/DN"
              },
              {
                "id": 116,
                "kind": "contact",
                "type": "XIO",
                "addr": "C10"
              }
            ],
            [
              {
                "id": 117,
                "kind": "contact",
                "type": "XIC",
                "addr": "C1"
              },
              {
                "id": 118,
                "kind": "contact",
                "type": "XIC",
                "addr": "T7/DN"
              }
            ]
          ]
        },
        {
          "id": 113,
          "kind": "output",
          "type": "OTL",
          "addr": "C2"
        }
      ]
    },
    {
      "id": 5,
      "rn": 4,
      "comment": "NS Yellow timer — 3 s",
      "elements": [
        {
          "id": 119,
          "kind": "contact",
          "type": "XIC",
          "addr": "C2"
        },
        {
          "id": 120,
          "kind": "block",
          "type": "TON",
          "addr": "T2",
          "pre": 3000
        }
      ]
    },
    {
      "id": 6,
      "rn": 5,
      "comment": "Advance NS Yellow → All Red 1",
      "elements": [
        {
          "id": 121,
          "kind": "contact",
          "type": "XIC",
          "addr": "C2"
        },
        {
          "id": 122,
          "kind": "contact",
          "type": "XIC",
          "addr": "T2/DN"
        },
        {
          "id": 123,
          "kind": "output",
          "type": "OTL",
          "addr": "C3"
        }
      ]
    },
    {
      "id": 7,
      "rn": 6,
      "comment": "Clear NS Yellow phase bit",
      "elements": [
        {
          "id": 124,
          "kind": "contact",
          "type": "XIC",
          "addr": "C2"
        },
        {
          "id": 125,
          "kind": "contact",
          "type": "XIC",
          "addr": "T2/DN"
        },
        {
          "id": 126,
          "kind": "output",
          "type": "OTU",
          "addr": "C2"
        }
      ]
    },
    {
      "id": 8,
      "rn": 7,
      "comment": "All Red 1 clearance timer — 1.5 s",
      "elements": [
        {
          "id": 127,
          "kind": "contact",
          "type": "XIC",
          "addr": "C3"
        },
        {
          "id": 128,
          "kind": "block",
          "type": "TON",
          "addr": "T3",
          "pre": 1500
        }
      ]
    },
    {
      "id": 9,
      "rn": 8,
      "comment": "Advance All Red 1 → EW Green",
      "elements": [
        {
          "id": 129,
          "kind": "contact",
          "type": "XIC",
          "addr": "C3"
        },
        {
          "id": 130,
          "kind": "contact",
          "type": "XIC",
          "addr": "T3/DN"
        },
        {
          "id": 131,
          "kind": "output",
          "type": "OTL",
          "addr": "C4"
        }
      ]
    },
    {
      "id": 10,
      "rn": 9,
      "comment": "Clear All Red 1 phase bit",
      "elements": [
        {
          "id": 132,
          "kind": "contact",
          "type": "XIC",
          "addr": "C3"
        },
        {
          "id": 133,
          "kind": "contact",
          "type": "XIC",
          "addr": "T3/DN"
        },
        {
          "id": 134,
          "kind": "output",
          "type": "OTU",
          "addr": "C3"
        }
      ]
    },
    {
      "id": 11,
      "rn": 10,
      "comment": "EW Green base timer — 20 s",
      "elements": [
        {
          "id": 135,
          "kind": "contact",
          "type": "XIC",
          "addr": "C4"
        },
        {
          "id": 136,
          "kind": "block",
          "type": "TON",
          "addr": "T4",
          "pre": 20000
        }
      ]
    },
    {
      "id": 12,
      "rn": 11,
      "comment": "EW ped extension timer — runs 5 s after T4 times out if ped request is latched (C11)",
      "elements": [
        {
          "id": 137,
          "kind": "contact",
          "type": "XIC",
          "addr": "C4"
        },
        {
          "id": 138,
          "kind": "contact",
          "type": "XIC",
          "addr": "T4/DN"
        },
        {
          "id": 139,
          "kind": "contact",
          "type": "XIC",
          "addr": "C11"
        },
        {
          "id": 140,
          "kind": "block",
          "type": "TON",
          "addr": "T8",
          "pre": 5000
        }
      ]
    },
    {
      "id": 13,
      "rn": 12,
      "comment": "Advance EW Green → EW Yellow  (immediately if no ped req, or after 5 s extension)",
      "elements": [
        {
          "id": 141,
          "kind": "parallel",
          "type": "parallel",
          "addr": "",
          "branches": [
            [
              {
                "id": 143,
                "kind": "contact",
                "type": "XIC",
                "addr": "C4"
              },
              {
                "id": 144,
                "kind": "contact",
                "type": "XIC",
                "addr": "T4/DN"
              },
              {
                "id": 145,
                "kind": "contact",
                "type": "XIO",
                "addr": "C11"
              }
            ],
            [
              {
                "id": 146,
                "kind": "contact",
                "type": "XIC",
                "addr": "C4"
              },
              {
                "id": 147,
                "kind": "contact",
                "type": "XIC",
                "addr": "T8/DN"
              }
            ]
          ]
        },
        {
          "id": 142,
          "kind": "output",
          "type": "OTL",
          "addr": "C5"
        }
      ]
    },
    {
      "id": 14,
      "rn": 13,
      "comment": "Clear EW Green phase bit",
      "elements": [
        {
          "id": 148,
          "kind": "parallel",
          "type": "parallel",
          "addr": "",
          "branches": [
            [
              {
                "id": 150,
                "kind": "contact",
                "type": "XIC",
                "addr": "C4"
              },
              {
                "id": 151,
                "kind": "contact",
                "type": "XIC",
                "addr": "T4/DN"
              },
              {
                "id": 152,
                "kind": "contact",
                "type": "XIO",
                "addr": "C11"
              }
            ],
            [
              {
                "id": 153,
                "kind": "contact",
                "type": "XIC",
                "addr": "C4"
              },
              {
                "id": 154,
                "kind": "contact",
                "type": "XIC",
                "addr": "T8/DN"
              }
            ]
          ]
        },
        {
          "id": 149,
          "kind": "output",
          "type": "OTU",
          "addr": "C4"
        }
      ]
    },
    {
      "id": 15,
      "rn": 14,
      "comment": "EW Yellow timer — 3 s",
      "elements": [
        {
          "id": 155,
          "kind": "contact",
          "type": "XIC",
          "addr": "C5"
        },
        {
          "id": 156,
          "kind": "block",
          "type": "TON",
          "addr": "T5",
          "pre": 3000
        }
      ]
    },
    {
      "id": 16,
      "rn": 15,
      "comment": "Advance EW Yellow → All Red 2",
      "elements": [
        {
          "id": 157,
          "kind": "contact",
          "type": "XIC",
          "addr": "C5"
        },
        {
          "id": 158,
          "kind": "contact",
          "type": "XIC",
          "addr": "T5/DN"
        },
        {
          "id": 159,
          "kind": "output",
          "type": "OTL",
          "addr": "C6"
        }
      ]
    },
    {
      "id": 17,
      "rn": 16,
      "comment": "Clear EW Yellow phase bit",
      "elements": [
        {
          "id": 160,
          "kind": "contact",
          "type": "XIC",
          "addr": "C5"
        },
        {
          "id": 161,
          "kind": "contact",
          "type": "XIC",
          "addr": "T5/DN"
        },
        {
          "id": 162,
          "kind": "output",
          "type": "OTU",
          "addr": "C5"
        }
      ]
    },
    {
      "id": 18,
      "rn": 17,
      "comment": "All Red 2 clearance timer — 1.5 s",
      "elements": [
        {
          "id": 163,
          "kind": "contact",
          "type": "XIC",
          "addr": "C6"
        },
        {
          "id": 164,
          "kind": "block",
          "type": "TON",
          "addr": "T6",
          "pre": 1500
        }
      ]
    },
    {
      "id": 19,
      "rn": 18,
      "comment": "Clear All Red 2 — cycle returns to NS Green (C1 resumes via OTE rung 0)",
      "elements": [
        {
          "id": 165,
          "kind": "contact",
          "type": "XIC",
          "addr": "C6"
        },
        {
          "id": 166,
          "kind": "contact",
          "type": "XIC",
          "addr": "T6/DN"
        },
        {
          "id": 167,
          "kind": "output",
          "type": "OTU",
          "addr": "C6"
        }
      ]
    },
    {
      "id": 20,
      "rn": 19,
      "comment": "─── PEDESTRIAN REQUESTS  ─  C10 = NS ped req  C11 = EW ped req ───",
      "elements": [
        {
          "id": 168,
          "kind": "contact",
          "type": "XIC",
          "addr": "X1"
        },
        {
          "id": 169,
          "kind": "output",
          "type": "OTL",
          "addr": "C10"
        }
      ]
    },
    {
      "id": 21,
      "rn": 20,
      "comment": "Clear NS ped request once the 5 s extension has run",
      "elements": [
        {
          "id": 170,
          "kind": "contact",
          "type": "XIC",
          "addr": "T7/DN"
        },
        {
          "id": 171,
          "kind": "output",
          "type": "OTU",
          "addr": "C10"
        }
      ]
    },
    {
      "id": 22,
      "rn": 21,
      "comment": "Latch EW pedestrian request",
      "elements": [
        {
          "id": 172,
          "kind": "contact",
          "type": "XIC",
          "addr": "X2"
        },
        {
          "id": 173,
          "kind": "output",
          "type": "OTL",
          "addr": "C11"
        }
      ]
    },
    {
      "id": 23,
      "rn": 22,
      "comment": "Clear EW ped request once the 5 s extension has run",
      "elements": [
        {
          "id": 174,
          "kind": "contact",
          "type": "XIC",
          "addr": "T8/DN"
        },
        {
          "id": 175,
          "kind": "output",
          "type": "OTU",
          "addr": "C11"
        }
      ]
    },
    {
      "id": 24,
      "rn": 23,
      "comment": "─── OUTPUTS ───",
      "elements": [
        {
          "id": 176,
          "kind": "contact",
          "type": "XIC",
          "addr": "C1"
        },
        {
          "id": 177,
          "kind": "output",
          "type": "OTE",
          "addr": "Y1"
        }
      ]
    },
    {
      "id": 25,
      "rn": 24,
      "comment": "",
      "elements": [
        {
          "id": 178,
          "kind": "contact",
          "type": "XIC",
          "addr": "C2"
        },
        {
          "id": 179,
          "kind": "output",
          "type": "OTE",
          "addr": "Y2"
        }
      ]
    },
    {
      "id": 26,
      "rn": 25,
      "comment": "NS Red — on whenever not NS Green and not NS Yellow",
      "elements": [
        {
          "id": 180,
          "kind": "contact",
          "type": "XIO",
          "addr": "C1"
        },
        {
          "id": 181,
          "kind": "contact",
          "type": "XIO",
          "addr": "C2"
        },
        {
          "id": 182,
          "kind": "output",
          "type": "OTE",
          "addr": "Y3"
        }
      ]
    },
    {
      "id": 27,
      "rn": 26,
      "comment": "",
      "elements": [
        {
          "id": 183,
          "kind": "contact",
          "type": "XIC",
          "addr": "C4"
        },
        {
          "id": 184,
          "kind": "output",
          "type": "OTE",
          "addr": "Y4"
        }
      ]
    },
    {
      "id": 28,
      "rn": 27,
      "comment": "",
      "elements": [
        {
          "id": 185,
          "kind": "contact",
          "type": "XIC",
          "addr": "C5"
        },
        {
          "id": 186,
          "kind": "output",
          "type": "OTE",
          "addr": "Y5"
        }
      ]
    },
    {
      "id": 29,
      "rn": 28,
      "comment": "EW Red — on whenever not EW Green and not EW Yellow",
      "elements": [
        {
          "id": 187,
          "kind": "contact",
          "type": "XIO",
          "addr": "C4"
        },
        {
          "id": 188,
          "kind": "contact",
          "type": "XIO",
          "addr": "C5"
        },
        {
          "id": 189,
          "kind": "output",
          "type": "OTE",
          "addr": "Y6"
        }
      ]
    }
  ],
  "comments": {
    "C2": "NS Yellow Phase",
    "C3": "All Red 1 Phase",
    "C4": "EW Green Phase",
    "C5": "EW Yellow Phase",
    "C6": "All Red 2 Phase",
    "C1": "NS Green Phase",
    "T1": "NS Green 20 s",
    "C10": "Ped NS Request",
    "T7": "NS ped ext 5 s",
    "T7/DN": "Ped ext done",
    "T2": "NS Yellow 3 s",
    "T3": "All Red 1  1.5 s",
    "T4": "EW Green 20 s",
    "C11": "Ped EW Request",
    "T8": "EW ped ext 5 s",
    "T8/DN": "Ped ext done",
    "T5": "EW Yellow 3 s",
    "T6": "All Red 2  1.5 s",
    "X1": "N/S Ped Button",
    "X2": "E/W Ped Button",
    "Y1": "NS Green light",
    "Y2": "NS Yellow light",
    "Y3": "NS Red light",
    "Y4": "EW Green light",
    "Y5": "EW Yellow light",
    "Y6": "EW Red light"
  }
}